<?php
/**
 * Created by phpstorm.
 * User: WML
 * Date: 2019/5/30 0030
 * Time: 17:09
 */
function objToArr($obj){
    return json_decode(json_encode($obj), true);
}
function objToJson($obj){
    return json_encode($obj,true);
}
function jsonToArr($json){
    return json_decode($json,true);
}
function getCateByPid($pid){
    $data = DB::table('district')->where('pid',$pid)->get();
    $datas = [];
    $data = objToArr($data);
    foreach($data as $key=>$value){
        $value['next'] = getCateByPid($value['id']);
        $datas[] = $value;
    }
    return $datas;
}